package com.bupt.consumer.controller;

import com.bupt.annotation.LoginRequired;
import com.bupt.order.client.OrderClient;
import com.bupt.order.dto.OrderDto;
import com.bupt.order.entity.Order;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
//@CrossOrigin
public class OrderConsumerController implements OrderClient {

    @Autowired
    private OrderClient orderClient;

    @Override
    @LoginRequired
    public List<Order> getAllOrders() {
        return orderClient.getAllOrders();
    }

    @Override
    @LoginRequired
    public List<Order> getOrdersByUserId(String userId) {
        return orderClient.getOrdersByUserId(userId);
    }

    @Override
    @LoginRequired
    public List<Order> getOrdersByModel(Order order) {
        return orderClient.getOrdersByModel(order);
    }

    @Override
    @LoginRequired
    public Map<String, Object> getOrdersCountByModel(Order order) {
        return orderClient.getOrdersCountByModel(order);
    }

    @Override
    public Map<String, Object> getTicketsSoldNumByModel(Order order) {
        return orderClient.getTicketsSoldNumByModel(order);
    }

    @Override
    @LoginRequired
    public void createOrder(OrderDto orderDto) {
        orderClient.createOrder(orderDto);
    }

    @Override
    public String getUserSessionTest() {
        return orderClient.getUserSessionTest();
    }
}
